import time

from openai import OpenAI
from volcenginesdkarkruntime import Ark


# 从文件中读取内容
def read_file_content(file_path):
    with open(file_path, "r", encoding="utf-8") as file:
        content = file.read()
        print(content)
        return content

def record_start_time():
    """记录请求开始时间并打印信息"""
    start_time = time.time()
    start_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(start_time))
    print(f"[START] Request at {start_str}")
    return start_time

def record_end_time(start_time):
    """记录请求结束时间，计算耗时并打印信息"""
    end_time = time.time()
    end_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(end_time))
    duration = end_time - start_time
    print(f"[END] Request completed at {end_str}")
    print(f"[DURATION] Request took {duration:.2f} seconds")
    return end_time

def init_openai_client():
    return OpenAI(
        base_url="https://ark.cn-beijing.volces.com/api/v3/",
        api_key="afb3a7b0-7e7b-4725-b3cd-06e3731bf95b"
    )

def init_Ark_client():
    return Ark(
        api_key="afb3a7b0-7e7b-4725-b3cd-06e3731bf95b",
    )
